import Mirai from "mirai-ts";
import { Message, Logger, check, MessageType, EventType } from "mirai-ts";
import 'module-alias/register'
import { findWowsUser,findWowsUserShipByTypeGrade } from '@/wows/find'
import answers from '@/utils/answers'
import commonUtils from "@/utils/commonUtils"
import moment from 'moment'
import axios from 'axios'
import chartImg from '@/chartImg/chartImg'
import {root} from '@/root/root'
import {searchImg} from '@/utils/sagiri'
import {sign} from '@/wows/sign'
// 摩尔斯码
import { decode, encode } from 'xmorse';
// 计算
import { evaluate } from 'mathjs';
// 黑名单
import{updateBlackList } from '@/utils/blackListUtil'

// dna
import DNAlist from '@/utils/dna'

// 碧蓝航线
import BlhxList from '@/utils/blhx'

// 对话信息封装
import talk from "@/talk/talk";

// 明日方舟
import MrfzMap from '@/utils/mrfz'

// 赛马娘
import SmnMap from '@/utils/smn'


const star = {
  1: "★☆☆☆☆☆",
  2: "★★☆☆☆☆",
  3: "★★★☆☆☆",
  4: "★★★★☆☆",
  5: "★★★★★☆",
  6: "★★★★★★",
}

// 老黄历
import {Almanac} from '@/utils/almanac'

// 正式
const qq = 2065104337;
// 测试
// const qq = 3448203404;
const mahConfig = {
  host: "localhost",
  port: 9876,
  authKey: "missilegaia",
  enableWebsocket: true,
};
const logger = new Logger();
const mirai = new Mirai(mahConfig);
const Path = require('path');
const fs = require('fs');

const almanac = new Almanac()

// 图设限制
let imgCount={}
let imgMax=60
// 黑名单
let blacklist = [
  "1487311510", // 平岛信子 姐夫群sb
  "1124979994",  // 拉进群舜踢的sb
  "1574911352", // 缺爱傻逼
  "2050945794", // 缺爱傻逼
  "2458786759", // 缺爱傻逼
  "751928983", // 不行就别玩了
  "1973995300",// 爱玩玩 不玩滚
  "1600300141", //日本福岛核废水洗地狗
]
// 从接口取用黑名单
async function setBlackList(){
  let tempBlacklist = await updateBlackList()
  console.log("blacklist",blacklist)
  if(!commonUtils.isNull(tempBlacklist)){
    blacklist = tempBlacklist
  }
}
// 定时任务
const cron = require("node-cron");

cron.schedule("0 0 * * * *", function() {
  imgCount={}
  console.log("重置限制");
  setBlackList()
  console.log("更新黑名单");
  // 更新老黄历
  almanac.updateAlmanac()
});
const vipGroupList = [
  1050053532
]
cron.schedule("0 0 15 * * *", function() {
  for(const index in vipGroupList){
    setTimeout(() => {
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Plain("三点lei？ 做咩啊！饮茶先啊！"));
      mirai.api.sendGroupMessage(messageChain, vipGroupList[index])
    }, 1000*parseInt(index));
  }
});

cron.schedule("0 0 * * * *", function() {
  imgCount={}
  console.log("重置限制");
  setBlackList()
  console.log("更新黑名单");
  // 更新老黄历
  almanac.updateAlmanac()
});


// 复读对象
let rereadMap={}
// 群噤声列表
interface forbidden {
  id: number,
  qq: number
}
const forbiddenMap:{[key:number]:forbidden | null }  = {}
setBlackList()
// 黑名单群
// 1079277169 禁言 大鸟转转转
function myReply(msg: MessageType.GroupMessage,messageChain: MessageType.MessageChain){
  if(msg.sender.id==759071738){
    // messageChain.push(Message.Plain(`\n爸爸！！！！`))
  }
  msg.reply(messageChain).then((response:any)=>{
    
    if(response.code==0){
      console.log("====成功====",msg.sender.group.id,msg.sender.group.name,msg.sender.id,msg.plain);
    }else{
      //{ code: 20, msg: 'Bot被禁言' } ====成功==== 1079277169 🍉CW要素存微，大鸟转转转酒吧404营业中 850514337
      console.log(response,"====报错====",msg.sender.group.id,msg.sender.group.name,msg.sender.id);
      if(response.msg=='Bot被禁言'){
        console.log("执行退群")
        mirai.api.quit(msg.sender.group.id)
      }
    }
  })
}



async function app() {
  await mirai.link(qq);
  // mirai.on("message", (msg) => {
  mirai.on("GroupMessage", async (msg) => {
    // 先进root命令
    root(mirai,msg);

    //判断是否噤声
    if(forbiddenMap[msg.sender.group.id]){
      return
    }
    // console.log(msg)
    let parameterList = msg.plain.trim().split(/ +/)
    if(["萌百","搜梗"].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      messageChain.push(Message.Plain("\nhttps://zh.moegirl.org.cn/index.php?search="+encodeURI(parameterList[1])))
      myReply(msg,messageChain)
      return
    }

    if(msg.plain.trim().indexOf('宝宝巴士')>-1 && msg.sender.id==397142989){
      let messageChain: MessageType.MessageChain = []
      // messageChain.push(Message.Plain(`潘叔叔又在吃屎了，大家可千万不能学他`))
      messageChain.push(Message.Plain(`警惕新型网络诈骗`))
      myReply(msg,messageChain)
      return
    }
    
    if(msg.plain.trim().indexOf("bot 网络异常！")>-1){
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Image(null, null,"./diaoImg/boom.png"))
      myReply(msg,messageChain)
      return
    }
    
    
    // if(["淦","操","草","屮","肏","艸"].indexOf(msg.plain.trim())>-1){
    //   if([638237897].includes(msg.sender.group.id)) return
    //   let messageChain: MessageType.MessageChain = []
    //   messageChain.push(Message.Plain(`淦（指沉没）`))
    //   myReply(msg,messageChain)
    //   return
    // }
    
   
    if(["计算","计算器",].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      messageChain.push(Message.Plain("\n"+evaluate(parameterList[1])))
      myReply(msg,messageChain)
      return
    }

    // 彩蛋对话
    let returnTalk = talk.eggTalk(msg)
    if(returnTalk){
      myReply(msg,returnTalk)
      return
    }

    let messageChainTalk = talk.vipTalk(msg, vipGroupList)
    if(messageChainTalk){
      myReply(msg,messageChainTalk)
      return
    }

    // 联动yuyuko
    if(["我爱你","老婆","誓约","做我老婆"].indexOf(parameterList[0])>-1){
      for(let message of msg.messageChain){
        if(message.type == 'At' && message.target == 2771589125){
          let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
          messageChain.push(Message.Plain("\n请不要想Peach yuyuko是我的"))
          myReply(msg,messageChain)
          return
        }
      }
    }

    
    // https://zh.moegirl.org.cn/index.php?search=114514
    
    // if(msg.plain.trim().indexOf("@")>-1){
    //   let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
    //   messageChain.push(Message.Plain(`是在叫我吗？不要复制艾特啊(加粗！标红！)`))
    //   myReply(msg,messageChain)
    //   return
    // }
    // console.log(msg);
    

    
    // 判断@
    if(!msg.isAt()){
      if(msg.plain==null || msg.plain==""){return}
      // 复读功能 reread 顺带剔除艾特bot的
      if(rereadMap[msg.sender.group.id]==null){
        rereadMap[msg.sender.group.id]={
          text:null,
          rereadList:[
          ]
        }
        return
      }
      // 判断发言是否重复
      if(rereadMap[msg.sender.group.id].text == msg.plain){return}
      // 判断发言人是否重复
      for(let reread of rereadMap[msg.sender.group.id].rereadList){
        if(reread.id==msg.sender.id && reread.text == msg.plain){return}
      }
      // 不同发言人数据压入
      if(rereadMap[msg.sender.group.id].rereadList.length>2){
        rereadMap[msg.sender.group.id].rereadList.shift()
      }
      rereadMap[msg.sender.group.id].rereadList.push({
        id:msg.sender.id,
        text:msg.plain
      })
      // 开始判断是否复读
      if(
        rereadMap[msg.sender.group.id].rereadList.length==3&&
        rereadMap[msg.sender.group.id].rereadList[0].text==msg.plain&&
        rereadMap[msg.sender.group.id].rereadList[1].text==msg.plain&&
        rereadMap[msg.sender.group.id].rereadList[2].text==msg.plain
      ){
        rereadMap[msg.sender.group.id].rereadList=[]
        rereadMap[msg.sender.group.id].text = msg.plain
        let messageChain: MessageType.MessageChain = [Message.Plain(msg.plain)]
        console.log(`复读触发 群${msg.sender.group.id} ${msg.sender.group.name}`)
        msg.reply(messageChain)
        // console.log(`复读触发 群${msg.sender.group.id} ${msg.sender.group.name}`)
      }     
      return
    }
    
    // 黑名单判断
    if(blacklist.indexOf(msg.sender.id+'')>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      messageChain.push(Message.Image(null, null,"./diaoImg/black.png"))
      console.log("========",msg.sender.group.id,msg.sender.id,"黑名单调用");
      myReply(msg,messageChain)

      messageChain = [Message.Plain(`${msg.sender.group.id}  ${msg.sender.id} 黑名单调用`)]
      
      // mirai.api.sendGroupMessage(messageChain,1050053532)
      mirai.api.sendFriendMessage(messageChain,759071738)
      return
    }
    //============================================================

    

    // bot噤声
    if(["闭嘴"].indexOf(msg.plain.trim())>-1){
      msg.sender.id
      msg.sender.group.id
      if(!forbiddenMap[msg.sender.group.id]){
        forbiddenMap[msg.sender.group.id]={
          id:msg.sender.group.id,
          qq:msg.sender.id
        }
        setTimeout(() => {
          forbiddenMap[msg.sender.group.id]=null
        }, 1000*60*5);

        let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
        messageChain.push(Message.Plain(`好嘛 歇了五分钟`))
        myReply(msg,messageChain)
      }

      return 
    }
    forbiddenMap
    
    if(["叫爸爸","更新黑名单"].indexOf(msg.plain.trim())>-1){
      if([759071738,2622749113,595137849].includes(msg.sender.id)){
        setBlackList()
        console.log("更新黑名单");
        let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
        messageChain.push(Message.Plain(`\n爸爸!`))
        myReply(msg,messageChain)
        return
      }else{
        let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
        messageChain.push(Message.Image(null, null,"./diaoImg/mjl.png"))
        myReply(msg,messageChain)
        return
      }
    }
    
    if(["叫爷爷"].indexOf(msg.plain.trim())>-1){
      if(msg.sender.id==759071738){
        let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
        messageChain.push(Message.Plain(`\n不行爷爷太老了!`))
        myReply(msg,messageChain)
        return
      }else{
        let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
        messageChain.push(Message.Image(null, null,"./diaoImg/mjl.png"))
        myReply(msg,messageChain)
        return
      }
    }
    if(["踩到屎了"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      let index = commonUtils.randomNum(0,DNAlist.length-1)
      messageChain.push(Message.Plain(`\n${DNAlist[index]}`))
      myReply(msg,messageChain)
      return
    }
    

    if(['我不爱你了',"滚啊","guna"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Image(null, null,"./diaoImg/dislike.jpg"))
      myReply(msg,messageChain)
      return
    }
    if(["戳一下"].indexOf(msg.plain.trim())>-1){
      
      let messageChain: MessageType.MessageChain = [Message.Poke(MessageType.PokeName.Poke)]
      msg.reply(messageChain)
      return
    }
    if(["处理一下"].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      console.log("字符画处理")
      if( await chartImg(msg.get("Image")?.url,msg.sender.id)){
        messageChain.push(Message.Image(null, null,"./chartImg/"+msg.sender.id+'.png'))
      }else{
        messageChain.push(Message.Plain("\n太大了 告辞"))
      }
      myReply(msg,messageChain)
      return 
    }
    // if(["找一下","搜图","搜一下"].indexOf(parameterList[0])>-1 
    if(["aabbccddee"].indexOf(parameterList[0])>-1 
      // && [648617532,1050053532,657681428,1128427506].indexOf(msg.sender.group.id)>-1
    ){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      console.log("搜图",msg.sender.group.id) 
      let index=0
      let beginMessageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      beginMessageChain.push(Message.Plain(`让我找找 稍等`))
      myReply(msg,beginMessageChain)
      if(Object.prototype.toString.call(msg.get("Image")?.url)=="[object String]"){
        let imgList = await searchImg(msg.get("Image")?.url as string)
        for(let img of imgList){
          if(img.similarity<50)continue
          let an:string|number = index+""
          if(!commonUtils.isNull(img.authorName)){
            an = img.authorName as string
          }
          if( await chartImg(msg.get("Image")?.url,msg.sender.id+an)){
            messageChain.push(Message.Image(null, null,"./chartImg/"+msg.sender.id+an+'.png'))
          }else{
            messageChain.push(Message.Plain("\n太大了 告辞 去连接看吧"))
          }
          // messageChain.push(Message.Image(null, img.thumbnail,null))
          messageChain.push(Message.Plain(`\n${img.url}`))
          messageChain.push(Message.Plain(`\n作者:${img.authorName}`))
          messageChain.push(Message.Plain(`\n相似:${img.similarity}`))
          messageChain.push(Message.Plain(`\n====================`))
          index++
          if(index>4) break
        }
      }else{
        let index=-1
        messageChain.push(Message.Plain("你图呢?"))
      }
      if(index == 0){
        messageChain.push(Message.Plain("这图怎么没味儿啊(指找不到相似度高)"))
      }
      myReply(msg,messageChain)
      return 
    }
    if(["签到"].indexOf(parameterList[0])>-1){
      myReply(msg,await sign(almanac,msg))
      return 
    }
    if(["q"].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      await axios({
        method: 'get',
        url:'http://api.qingyunke.com/api.php?key=free&appid=0&msg='+encodeURI(parameterList[1]),
        data: {}
      }).then((response:any) => {
        messageChain.push(Message.Plain(response.data.content.replace(/{br}/g,'\n')))
        myReply(msg,messageChain)
      })
      return
    }
    if(["诗"].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      await axios({
        method: 'get',
        url:'http://poetry.apiopen.top/sentences',
        data: {}
      }).then((response:any) => {
        messageChain.push(Message.Plain('\n'+response.data.result.from))
        messageChain.push(Message.Plain('\n'+response.data.result.name))
        myReply(msg,messageChain)
      })
      return
    }
    if(["噗噗"].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      await axios({
        method: 'get',
        url:'https://chp.shadiao.app/api.php',
        data: {}
      }).then((response:any) => {
        messageChain.push(Message.Plain('\n'+response.data))
        myReply(msg,messageChain)
      })
      return
    }
    if(["摩尔斯编码"].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      messageChain.push(Message.Plain('\n'+encode(parameterList[1])))
      myReply(msg,messageChain)
      return
    }
    if(["摩尔斯解码"].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      messageChain.push(Message.Plain('\n'+decode(parameterList[1])))
      myReply(msg,messageChain)
      return
    }
    if(["周几"].indexOf(msg.plain.trim())>-1){
      
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      messageChain.push(Message.Plain(commonUtils.getWeekDay(moment().format("YYYY-MM-DD"))+'啊胸弟！'))
      myReply(msg,messageChain)
      return
    }
    
    if(['憨批',"憨憨"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Image(null, null,"./diaoImg/hp.jpg"))
      myReply(msg,messageChain)
      return
    }
    if(['你能帮帮我吗？','你能帮帮我吗','能帮帮我吗'].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Image(null, null,"./diaoImg/bbw.jpg"))
      myReply(msg,messageChain)
      return
    }
    if(parameterList[0] == '答案之书'){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      if(commonUtils.isNull( parameterList[1])){
        messageChain.push(Message.Plain("\n你的问题呢？"))
        myReply(msg,messageChain)
        return
      }
      let index = commonUtils.randomNum(0,answers.length-1)
      console.log(answers[index])
      messageChain.push(Message.Plain("\n"+answers[index]))
      myReply(msg,messageChain)
      return
    }
    
    if(["抽个老婆"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      let index = commonUtils.randomNum(0,BlhxList.length-1)
      messageChain.push(Message.Plain(`\n${BlhxList[index].name}`))
      messageChain.push(Message.Plain(`\n稀有度 ${BlhxList[index].rarity}`))
      messageChain.push(Message.Image(null, 
        BlhxList[index].imglist[BlhxList[index].imglist.length -1]
        , null)
      )
      if(BlhxList[index].touch2text){
        messageChain.push(Message.Plain(`\n${BlhxList[index].touch2text}`))
      }
      myReply(msg,messageChain)

      if(BlhxList[index].touch2){
        let strList = BlhxList[index].touch2?.split("/")
        if(strList){
          let str = strList[strList.length-1].replace('.mp3',".amr")
          messageChain = [Message.Voice(null,null,str)]
          msg.reply(messageChain)
          console.log(str)
        }
      }
      return
    }
    if(["寻访干员"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      let randomNum =  Math.random()*100
      if(randomNum<2){
        randomNum=6
      }else if(randomNum<10){
        randomNum=5
      }else if(randomNum<60){
        randomNum=4
      }else{
        randomNum=3
      }

      let index = commonUtils.randomNum(0,MrfzMap[randomNum].length-1)
      messageChain.push(Message.Plain(`\n${MrfzMap[randomNum][index].name}`))
      messageChain.push(Message.Plain(`\n稀有度 ${star[randomNum]}`))
      messageChain.push(Message.Image(null, 
        MrfzMap[randomNum][index].imglist[MrfzMap[randomNum][index].imglist.length -1]
        , null)
      )
      myReply(msg,messageChain)
      return
    }
    if(["抽个🐎","抽个马"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      let randomNum =  Math.random()*100
      if(randomNum<10){
        randomNum=3
      }else if(randomNum<40){
        randomNum=2
      }else{
        randomNum=1
      }

      let index = commonUtils.randomNum(0,SmnMap[randomNum].length-1)
      messageChain.push(Message.Plain(`\n${SmnMap[randomNum][index].name}`))
      messageChain.push(Message.Plain(`\n稀有度 ${star[randomNum]}`))
      if(SmnMap[randomNum][index].attribute){
        messageChain.push(Message.Plain(`\n五维 ${SmnMap[randomNum][index].attribute}`))
      }
      messageChain.push(Message.Image(null, 
        SmnMap[randomNum][index].imglist[SmnMap[randomNum][index].imglist.length -1]
        , null)
      )
      myReply(msg,messageChain)
      return
    }
    if(["艹"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      //计数
      if(commonUtils.isNull(imgCount[msg.sender.id])){
        imgCount[msg.sender.id]=0
      }else{
        imgCount[msg.sender.id]++
      }
      if(imgCount[msg.sender.id]>imgMax){
        messageChain.push(Message.Image(null, null,"./憨批物料/压缩/殉爆2.png"))
        messageChain.push(Message.Plain(`\n你的牛子过热殉爆了 歇会吧(整点重置)`))
        myReply(msg,messageChain)
        return
      }

      // 图片取用
      let imgs = fs.readdirSync("D:/mirai/magia-mcl/data/net.mamoe.mirai-api-http/images/img");
      let index = commonUtils.randomNum(1,imgs.length)
      console.log(imgs.length,index,imgs[index-1])
      
      messageChain.push(Message.Image(null, null,"./img/"+imgs[index-1]))
      // messageChain.push(Message.Plain(`\n${imgs[index-1]}`))
      messageChain.push(Message.Plain(`\n${imgCount[msg.sender.id]}/${imgMax}`))
      myReply(msg,messageChain)
      return
    }

    // if(["艹"].indexOf(msg.plain.trim())>-1){
    //   let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
    //   console.log("艹")      
    //   messageChain.push(Message.Image(null, null,"./diaoImg/sbsj.png"))
    //   messageChain.push(Message.Plain(`\n总有傻逼手贱`))
    //   myReply(msg,messageChain)
    //   return
    // }


    if(["爬","滚","爪巴","wdnmd"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Image(null, null,"./diaoImg/gun.jpg"))
      myReply(msg,messageChain)
      return
    }
    if(["废物","辣鸡","垃圾","要你何用","要你有啥用","什么垃圾","废物东西","废物bot"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Image(null, null,"./diaoImg/gun.jpg"))
      myReply(msg,messageChain)
      return
    }

    // 指定人的特殊对话
    if(["老婆"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      if([1584474212].indexOf( msg.sender.id)>-1){
        messageChain.push(Message.Plain(`啊? 你要给我买显卡吗？`))  
        myReply(msg,messageChain)
        return
      }
    }
    if(["老婆"].indexOf(msg.plain.trim())>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      if([1067559022].indexOf( msg.sender.id)>-1){
        messageChain.push(Message.Plain(`哎~先洗澡？还是先吃饭？还是，要·我·呢？`))  
        myReply(msg,messageChain)
        return
      }
    }
    
    
    if(["好好说话",'hhsh'].indexOf(parameterList[0])>-1){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
      if( commonUtils.isNull(parameterList[1])){
        messageChain.push(Message.Plain(`需要翻译什么？`))
      }else{
        await axios({
          method: 'post',
          url:'https://lab.magiconch.com/api/nbnhhsh/guess',
          data: {text:parameterList[1]}
        }).then((response:any) => {
          if(commonUtils.isNull(response.data[0].trans)){
            messageChain.push(Message.Plain('这怪话实在翻译不出来'))
          }else{
            messageChain.push(Message.Plain(response.data[0].trans.toString()))
          }
          
        })
      }
      myReply(msg,messageChain)
      return
    }



    // 指定对话 艾特对话 @对话
    returnTalk = talk.atTalk(msg)
    if(returnTalk){
      myReply(msg,returnTalk)
      return
    }

    if(parameterList[0] == '帮助'){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id)]
    
      messageChain.push(Message.Plain(`\n内容太长了 去链接看吧`));
      messageChain.push(Message.Plain(`\n开源了：https://gitee.com/missile_xuan/mgaia-mirai-ts-open/blob/master/README.md`));
      myReply(msg,messageChain)
      return
    }
    
    if(parameterList[0] == '水表'){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id),...await findWowsUser(parameterList[1].toLowerCase(),parameterList[2])]
      messageChain.push(Message.Plain(`\n=======================`));
      messageChain.push(Message.Plain(`\n查看帮助请 @bot 帮助`));
      messageChain.push(Message.Plain(`\n开源了：https://gitee.com/missile_xuan/mgaia-mirai-ts-open`));
      messageChain.push(Message.Plain(`\n另外友情推广更强劲的战绩bot:2771589125  西行寺雨季制作`));
      myReply(msg,messageChain)
      return
    }
    

    if(parameterList[0] == '单船'){
      let messageChain: MessageType.MessageChain = [Message.At(msg.sender.id),...await findWowsUserShipByTypeGrade(parameterList[1].toLowerCase(),parameterList[2],parameterList[3].toLowerCase(),parameterList[4])]
      messageChain.push(Message.Plain(`\n=======================`));
      messageChain.push(Message.Plain(`\n查看帮助请 @bot 帮助`));
      // messageChain.push(Message.Plain(`\n开源了：https://gitee.com/missile_xuan/mgaia-mirai-ts`));
      myReply(msg,messageChain)
      return
    }

    if(parameterList[0] == '最牛批的上校是谁'){
      let messageChain: MessageType.MessageChain = []
      messageChain.push(Message.Plain(`\n 那一定是vicpan`))
      myReply(msg,messageChain)
      return
    }

    // 兜底返还
    let messageChain: MessageType.MessageChain = []
    messageChain.push(Message.Plain(`阿巴阿巴阿巴(装傻) \n@bot 帮助`));
    myReply(msg,messageChain)
    return    
  });

  mirai.listen();
}

app();
